<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class User_Controller extends CI_Controller {
    
    function __construct()
	{
		parent::__construct();

		$this->load->model('user_model');
	}

    public function index() 
    {
        $data['user_list'] = $this->user_model->get_all();
        $this->load->view('panel/users/show_users', $data);
    }
    
    public function show_users() {
        # code...
    }

    /**
     * Show edit form
     *
     * @param int $user_id
     */
    public function show_edit_form($user_id) {
        # code...
        $data['user_list'] = $this->user_model->get_all_by_user_id($user_id);
        $this->load->view('panel/users/edit', $data);
    }

    /**
     * Do the editing of the user
     *
     * @param int $user_id
     */
    public function edit($user_id) {
        # code...
    }

    /**
     * Show add user form
     */
    public function show_add_form() {
        # code...get_role
        $data['role_list'] = $this->user_model->get_role();
        $this->load->view('panel/users/add', $data);
    }

    /**
     * Do the adding a user
     */
    public function create() {
        # code...
        if(!$this->input->post()) redirect(PANEL_URL.'/user/show_add_form');
        
        $this->user_model->add_by_post($this->input->post());

        redirect(PANEL_URL . '/user');
        
    }

    /**
     * Remove a user by id
     */
    public function remove($user_id) {
        # code...
    }

}

/* End of file user_controller.php */
/* Location: ./application/controllers/panel/user_controller.php */